package com.asset.inventory.view

import android.content.Intent
import com.asset.inventory.R
import com.asset.inventory.base.BaseActivity
import com.asset.inventory.databinding.ActivitySplashBinding
import com.asset.inventory.viewModel.SplashViewModel
import com.asset.inventory.BR
import com.asset.inventory.kt.startActivity
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

/**
 *    @author : sibb
 *    date   : 21-3-16
 *    desc   : 欢迎页面
 */
class SplashActivity: BaseActivity<SplashViewModel,ActivitySplashBinding>() {

    override fun getLayoutId(): Int = R.layout.activity_splash

    override fun initVariableId(): Int = BR.splashViewModel

    override fun initViewModel(): Class<SplashViewModel> = SplashViewModel::class.java

    override fun initView() {
        GlobalScope.launch (Dispatchers.Main){
            delay(2000)
            enterLoginPage()
        }
    }


    private fun enterLoginPage() {
        startActivity<LoginActivity>(this)
        finish()
    }
}